import url from '@/static/config'
import {h} from "vue"
export interface UserQueryType {
  username: string
  nick_name: string
  user_phone: string
}

export interface UserListType {
  id: number
  username: string
  email: string
  nick_name: string
  user_phone: string
  status: 0|1
  icon: string
  note: string
  create_time: string
  login_time: string
}

export interface UserAddType extends UserQueryType{
  icon: string
  email: string
}

export interface UserUpdateType extends UserAddType{
  id: number|string
}

export const userListColumns = [
  {
    title: "账号",
    key: "username",
    align: 'center'
  },
  {
    title: "用户名",
    key: "nick_name",
    align: 'center'
  },
  {
    title: "头像",
    key: "icon",
    align: 'center',
    width: 160,
    render(row: UserListType) {
      if (row.icon) {
        return h('img', {
          src: url + "static/images/" + row.icon,
          height: 38
        })
      }
      return ''
    }
  },
  {
    title: "邮箱",
    key: "email",
    align: 'center'
  },
  {
    title: "电话",
    key: "user_phone",
    align: 'center'
  },
  {
    title: "状态",
    key: "status",
    align: 'center',
    render(row:UserListType){
      if (row.status === 0) {
        return '禁用'
      }
      if (row.status === 1) {
        return '启用'
      }
      return row.status
    }
  }
]
